package com.kt.emall.product.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

/**
 * Description: redisson配置文件
 * Created with IntelliJ IDEA.
 *
 * @author: KamTeng
 * Date: 2021/8/14
 */
@Configuration
public class ProductRedissonConfig {

    /**
     * 所有对redisson的使用都是通过RedissonClient对象
     * @return Redisson.create(config);
     */
    @Bean(destroyMethod = "shutdown")
    RedissonClient redissonClient() throws IOException {
        // 创建配置
        Config config = new Config();
        config.useSingleServer()
                .setAddress("redis://192.168.56.11:6379");
        // 根据Config对象创建出RedissonClient实例
        return Redisson.create(config);
    }
}
